package com.example.sneakerappforme1105.adapter;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import com.example.sneakerappforme1105.SaleFragment.DeliverFragment2;
import com.example.sneakerappforme1105.SaleFragment.PaidFragment2;

import java.util.List;

public class ClassPagerAdapter extends FragmentStateAdapter {
    private List<String> mTitleList; // 声明一个标题文字列表, 服装、电器

    public ClassPagerAdapter(FragmentActivity fa, List<String>titleList) {
        super(fa);  // fa 碎片管理器
        mTitleList = titleList;
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {  // createFragment 如其名 new Fragment
        if(position == 0){
            //展示服装，第一页
            return new PaidFragment2();  // 嵌套Fragment 待处理，已付款
        }else{
            return new DeliverFragment2();   // 待收货，发货
        }
    }

    @Override
    public int getItemCount() {
        return mTitleList.size();
    }
}


